var _Z = {
	    "tb0": {
	        "jusyy": "field10774",
	        "baodrq": "field10785",
	        "zhidrq": "field10768",
	        "zhiw1": "field10795",
	        "diaorbmdbs111": "field10814",
	        "test": "field10826",
	        "diaorjxmc": "field10790",
	        "dcqhsfw": "field10801",
	        "drgsfb": "field10794",
	        "diaodqjzgw": "field10781",
	        "diaordh1": "field10802",
	        "diaodlx": "field10786",
	        "diaodyy": "field10788",
	        "anqjb": "field10792",
	        "diaorbmdbs11": "field10806",
	        "diaodqgw": "field10780",
	        "yuangbh": "field10777",
	        "shenhr": "field10769",
	        "diaorgssjrs": "field10828",
	        "diaorjxbh": "field10789",
	        "daycs": "field10772",
	        "beiz": "field10773",
	        "xianggdh": "field10775",
	        "wageFlag": "field10816",
	        "diaorbmsjs111": "field10815",
	        "shenhrq": "field10770",
	        "diaorbmbh111": "field10809",
	        "faqrq": "field10764",
	        "diaorzwbh111": "field10810",
	        "fuj": "field10766",
	        "duo": "field10797",
	        "diaorbm": "field10782",
	        "zhidr": "field10767",
	        "inPostRealityQty": "field10824",
	        "jihbzs111": "field10812",
	        "jihbzs11": "field10804",
	        "diaorbmsjs11": "field10807",
	        "inDepartmentPlanQty": "field10821",
	        "yuangxm": "field10776",
	        "authorizedFlag": "field10817",
	        "yewgwbh111": "field10811",
	        "diaordh111": "field10808",
	        "inPostPLanQty": "field10823",
	        "diaorbmbh1": "field10803",
	        "inPostFlag": "field10818",
	        "inCompanyRealityQty": "field10820",
	        "danjbh": "field10761",
	        "shenqr": "field10762",
	        "drhsfw": "field10800",
	        "diaodrq": "field10784",
	        "diaorbmmc2": "field10827",
	        "suosbm": "field10778",
	        "diaorjxsxrq": "field10791",
	        "shijrs111": "field10813",
	        "inCompanyPlanQty": "field10819",
	        "diaorywgw": "field10783",
	        "inDepartmentRealityQty": "field10822",
	        "gangw": "field10765",
	        "zhiw": "field10779",
	        "shijrs11": "field10805",
	        "hrDocCode": "field10825",
	        "bianz": "field10796",
	        "sffhgwxz": "field10799",
	        "bum": "field10763",
	        "danjzt": "field10771",
	        "suosgsfb": "field10793",
	        "diaodbz": "field10787",
	        "shifkqy": "field10798"
	    }
	};

/**
 * 调动人
 */
var employeeId = _Z.tb0.yuangxm;
/**
 * 调动工号
 */
var employeeCode = _Z.tb0.yuangbh;
/**
 * 调动标志
 */
var removeFlag = _Z.tb0.diaodbz;
/**
 * 调入门店编号
 */
var inShopId = _Z.tb0.diaordh111;
/**
 * 调入部门编号
 */
var inOfficeId = _Z.tb0.diaorbmbh111;
/**
 * 调入职务编号
 */
var dutyId = _Z.tb0.diaorzwbh111;

/**
 * 薪资状态
 */
var wageFlag = _Z.tb0.sffhgwxz;
/**
 * 编制状态
 */
var authorizedFlag = _Z.tb0.bianz;
/**
 * 调入岗位类型
 */
var inPostFlag = _Z.tb0.diaodlx;
/**
 * 调入公司定编人数
 */
var inCompanyPlanQty = _Z.tb0.inCompanyPlanQty;
/**
 * 实际人数
 */
var inCompanyRealityQty = _Z.tb0.inCompanyRealityQty;
/**
 * 调入部门定遍数
 */
var inDepartmentPlanQty = _Z.tb0.inDepartmentPlanQty;
/**
 * 调入部门实际数
 */
var inDepartmentRealityQty = _Z.tb0.inDepartmentRealityQty;
/**
 * 调入岗位定编人数
 */
var inPostPLanQty = _Z.tb0.inPostPLanQty;
/**
 * 调入岗位实际人数
 */
var inPostRealityQty = _Z.tb0.inPostRealityQty;
/**
 * 调入后岗位类型
 */
var dcqhsfw = _Z.tb0.dcqhsfw;

/**
 * 调动日期
 */
var transferDate = _Z.tb0.diaodrq;
/**
 * 报到日期
 */
var registrationDate = _Z.tb0.baodrq;

jQuery(document).ready(function(){
	setIsHrm();
	setRemoveTypeInfo();
	//调动人
	_C.bindChange(employeeId,function(){
		setRemoveTypeInfo();
	});
	//调动标志
	_C.bindChange(removeFlag,function(){
		setRemoveTypeInfo();
	});
	//调入门店编号
	_C.bindChange(inShopId,function(){
		setRemoveTypeInfo();
	});
	//调入部门编号
	_C.bindChange(inOfficeId,function(){
		setRemoveTypeInfo();
	});
	//调入职务编号
	_C.bindChange(dutyId,function(){
		setRemoveTypeInfo();
	});
	
	//用户自定义验证
	window.checkCustomize = function(){
		//验证报到日期 不能大于 调动日期
		var beginDate=jQuery("#"+transferDate).val();  
		var endDate=jQuery("#"+registrationDate).val();  
		var d1 = new Date(beginDate.replace(/\-/g, "\/"));  
		var d2 = new Date(endDate.replace(/\-/g, "\/")); 
		if(beginDate!=""&&endDate!=""&& d1>d2 ){
			window.top.Dialog.alert("报到日期不能小于调动日期");
			return false;
		}
		return true;
	};
});


/**
 * 设置异动类型信息
 */
function setRemoveTypeInfo(){
	let employeeIdValue = jQuery('#'+employeeId).val();	//调动人
	let removeFlagValue = jQuery('#'+removeFlag).val();	//调动标志
	let inShopIdValue = jQuery('#'+inShopId).val();		//调入门店编号
	let inOfficeIdValue = jQuery('#'+inOfficeId).val();	//调入部门编号
	let dutyIdValue = jQuery('#'+dutyId).val();			//调入职务编号
	if(
		_F.null2String(employeeIdValue) != '' &&
		_F.null2String(removeFlagValue) != '' &&
		_F.null2String(inShopIdValue) != '' &&
		_F.null2String(inOfficeIdValue) != '' &&
		_F.null2String(dutyIdValue) != '' 
	){
		let url = "/HrApi.getRemoveTypeInfo.app";
		let data = {
			shopId : inShopIdValue,
			employeeId : employeeIdValue,
			removeFlag : removeFlagValue,
			inShopId : inShopIdValue,
			inOfficeId : inOfficeIdValue,
			dutyId : dutyIdValue
		};
		let result = _C.ajaxJson(url,data);
		if(result){
			_C.v(wageFlag,result.wageFlag);
			_C.v(authorizedFlag,result.authorizedFlag);
			let inPostFlagVal = result.inPostFlag;
			if(inPostFlagVal==0 || inPostFlagVal==1 || inPostFlagVal==5){
				_C.v(dcqhsfw,result.inPostFlag);
				_C.v(inPostFlag,result.inPostFlag);
				displayAllmenu();
			}else{
				window.top.Dialog.alert("调入岗位类型只能是部门第一负责人,单位第一负责人,其他");
				enableAllmenu();
			}
			_C.v(inCompanyPlanQty,result.inCompanyPlanQty);
			_C.v(inCompanyRealityQty,result.inCompanyRealityQty);
			_C.v(inDepartmentPlanQty,result.inDepartmentPlanQty);
			_C.v(inDepartmentRealityQty,result.inDepartmentRealityQty);
			_C.v(inPostPLanQty,result.inPostPLanQty);
			_C.v(inPostRealityQty,result.inPostRealityQty);
		}else{
			_C.v(wageFlag,"");
			_C.v(authorizedFlag,"");
			_C.v(dcqhsfw,"");
			_C.v(inPostFlag,"");
			_C.v(inCompanyPlanQty,"");
			_C.v(inCompanyRealityQty,"");
			_C.v(inDepartmentPlanQty,"");
			_C.v(inDepartmentRealityQty,"");
			_C.v(inPostPLanQty,"");
			_C.v(inPostRealityQty,"");
			_C.vbrowser(inShopId,null,"","");
			_C.vbrowser(inOfficeId,null,"","");
			_C.vbrowser(dutyId,null,"","");
		}
	}
}

/**
 * 判断是否为人事管理员
 */
function setIsHrm(){
	jQuery("#isHrm").hide();
	let url = "/HrApi.isHrm.app";
	var o = _C.ajax(url,{},"json");
	if(o){
		jQuery("#isHrm").show();
	}else{
		jQuery("#isHrm").hide();	
	}
}